package com.lly.songhigh.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import com.lly.songhigh.R;
import com.lly.songhigh.constant.URL;


/**
 * Created by dllo on 15/10/20.
 */
public class SingerFragment extends BaseFragment implements RadioGroup.OnCheckedChangeListener {
    private RadioGroup rg_sin_tab;
    private FragmentTransaction transaction;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fr_singer, null);
        initView(view);
        return view;
    }

    private void initView(View view) {
        rg_sin_tab = (RadioGroup) view.findViewById(R.id.rg_sin_tab);
        //设置监听
        rg_sin_tab.setOnCheckedChangeListener(this);
        transaction = getChildFragmentManager().beginTransaction();
        transaction.replace(R.id.tabView0, SingerClassifyFragment.newInstance(URL.SINGER_TOP)).addToBackStack(null);
        transaction.commit();
    }
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.rb_sin_top100:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView0, SingerClassifyFragment.newInstance(URL.SINGER_TOP));
                transaction.commit();
                break;
            case R.id.rb_sin_popular:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView0, SingerClassifyFragment.newInstance(URL.RECENTLY_HOT));
                transaction.commit();
                break;
            case R.id.rb_sin_chinese:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView0, new ChineseFragment());
                transaction.commit();
                break;
            case R.id.rb_sin_eu:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView0, new EuropeAmericaFragment());
                transaction.commit();
                break;
            case R.id.rb_sin_ja:
                transaction = getChildFragmentManager().beginTransaction();
                transaction.replace(R.id.tabView0, new JapanKoreaFragment());
                transaction.commit();
                break;
        }
    }

}
